package com.bwf.generic;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/24 10:47
 * @Copyright 博为峰
 */
public class GenericDemo02 {
    public static void main(String[] args) {
        final ArrayList<String> strings = new ArrayList<>();
        strings.add("a");
        ite(strings);
//        final Iterator<String> iterator = strings.iterator();
//        while (iterator.hasNext()){
//            final String next = iterator.next();
//        }
        final ArrayList<Integer> integers = new ArrayList<>();
        integers.add(6);
        ite(integers);
//        final Iterator<Integer> iterator2 = integers.iterator();
//        while (iterator2.hasNext()){
//            final Integer next = iterator2.next();
//        }
    }
    //通配符
    public static void ite(ArrayList<?> arrayList) {
        final Iterator<?> iterator2 = arrayList.iterator();
        while (iterator2.hasNext()) {
            System.out.println(iterator2.next());
        }
    }
}
